package com.javaclimb.filmbuy.dao;

import com.javaclimb.filmbuy.entity.GoodsInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * 电影详情dao层
 */
@Repository
public interface GoodsInfoDao extends Mapper<GoodsInfo> {
    /*根据电影名称查询列表*/
    List<GoodsInfo> findByName(@Param("name")String name);

    /*根据电影类型查询最新的10条电影数据*/
    @Select("select * from goods_info where typeId =#{typeId} order by id desc limit 10")
    List<GoodsInfo> findByTypeId(@Param("typeId")Integer typeId);
    /*热门电影*/
    @Select("select * from goods_info where recommend='是' order by id desc")
    List<GoodsInfo> findRecommendGoods();
    /*热映电影*/
    @Select("select * from goods_info order by sales desc")
    List<GoodsInfo> findHotSalesGoods();

    /*根据用户id和level查询已经看过的电影*/
    List<GoodsInfo> getOrderGoods(@Param("userId")Long userId, @Param("level")Integer level);

    /*根据关键字搜索商品*/
    List<GoodsInfo> searchGoods(String text);
}


